From 5551fc67543356cee95ee9d46fbcfda728ac9a5c Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Thu, 3 Nov 2005 13:29:30 +0000 Subject: [PATCH] Rename the variables for the color bitmap to have "color" in their name, 2005-11-03 Tor Lillqvist * gdk/win32/gdkcursor-win32.c (pixbuf_to_hbitmaps_alpha_winxp): Rename the variables for the color bitmap to have "color" in their name, for similarity with pixbuf_to_hbitmaps_normal(). Create a color bitmap for the mask, too, instead of creating a b&w bitmap with CreateBitmap(). Set up the mask bitmap's contents, ones for those pixels in the color bitmap where the alpha is zero, zero for other pixels. We used to use an unitialized mask bitmap! This meant that icons and cursors created presumably worked more or less by accident. Totally blank icons with zero alpha everywhere (as used by gtktrayicon.c) definitely did not work as expected. --- ChangeLog | 11 ++++++++++ ChangeLog.pre-2-10 | 11 ++++++++++ gdk/win32/gdkcursor-win32.c | 44 ++++++++++++++++++++++--------------- 3 files changed, 48 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index e2e7f9513b..07a6f7e87a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2005-11-03 Tor Lillqvist + * gdk/win32/gdkcursor-win32.c (pixbuf_to_hbitmaps_alpha_winxp): + Rename the variables for the color bitmap to have "color" in their + name, for similarity with pixbuf_to_hbitmaps_normal(). Create a + color bitmap for the mask, too, instead of creating a b&w bitmap + with CreateBitmap(). Set up the mask bitmap's contents, ones for + those pixels in the color bitmap where the alpha is zero, zero for + other pixels. We used to use an unitialized mask bitmap! This + meant that icons and cursors created presumably worked more or + less by accident. Totally blank icons with zero alpha everywhere + (as used by gtktrayicon.c) definitely did not work as expected. + * gtk/Makefile.am: Include gtkstatusicon.c on all platforms. * gtk/gtkstatusicon.c: Implement for Win32. Use code from diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index e2e7f9513b..07a6f7e87a 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,5 +1,16 @@ 2005-11-03 Tor Lillqvist + * gdk/win32/gdkcursor-win32.c (pixbuf_to_hbitmaps_alpha_winxp): + Rename the variables for the color bitmap to have "color" in their + name, for similarity with pixbuf_to_hbitmaps_normal(). Create a + color bitmap for the mask, too, instead of creating a b&w bitmap + with CreateBitmap(). Set up the mask bitmap's contents, ones for + those pixels in the color bitmap where the alpha is zero, zero for + other pixels. We used to use an unitialized mask bitmap! This + meant that icons and cursors created presumably worked more or + less by accident. Totally blank icons with zero alpha everywhere + (as used by gtktrayicon.c) definitely did not work as expected. + * gtk/Makefile.am: Include gtkstatusicon.c on all platforms. * gtk/gtkstatusicon.c: Implement for Win32. Use code from diff --git a/gdk/win32/gdkcursor-win32.c b/gdk/win32/gdkcursor-win32.c index 85e7fb6f30..110506b74f 100644 --- a/gdk/win32/gdkcursor-win32.c +++ b/gdk/win32/gdkcursor-win32.c @@ -651,41 +651,49 @@ pixbuf_to_hbitmaps_alpha_winxp (GdkPixbuf *pixbuf, * http://www.dotnet247.com/247reference/msgs/13/66301.aspx */ HBITMAP hColorBitmap, hMaskBitmap; - guchar *indata, *inrow; - guchar *outdata, *outrow; - gint width, height, i, j, rowstride; + guchar *indata, *inrow, *maskdata, *maskrow; + guchar *colordata, *colorrow; + gint width, height, i, j, rowstride, bmstride; width = gdk_pixbuf_get_width (pixbuf); /* width of icon */ height = gdk_pixbuf_get_height (pixbuf); /* height of icon */ - hColorBitmap = create_alpha_bitmap (width, height, &outdata); + hColorBitmap = create_alpha_bitmap (width, height, &colordata); if (!hColorBitmap) return FALSE; - hMaskBitmap = CreateBitmap (width, height, 1, 1, NULL); + hMaskBitmap = create_color_bitmap (width, height, &maskdata); if (!hMaskBitmap) { DeleteObject (hColorBitmap); return FALSE; } - /* rows are always aligned on 4-byte boundarys, but here our pixels are always 4 bytes */ + bmstride = width * 3; + if (bmstride % 4 != 0) + bmstride += 4 - (bmstride % 4); + indata = gdk_pixbuf_get_pixels (pixbuf); rowstride = gdk_pixbuf_get_rowstride (pixbuf); for (j=0; j